3.26. Serial odd-even transposition sort of an n-element list can sort the list in considerably fewer than n phases. As an extreme example, if the input list is already sorted, the algorithm requires 0 phases. a. Write a serial Is sorted function that determines whether a list is sorted. b. Modify the serial odd-even transposition sort program so that it checks whether the list is sorted after each phase. c. If this program is tested on a random collection of n-element lists, roughly what fraction get improved performance by checking whether the list is sorted? | |
| View Solution | |
| << Back | Next >> |